﻿using FoodModel;
using J.FoodManageGet.Application.Command.BenchTableCommand;
using J.FoodRepository.InterFace;
using MediatR;

namespace J.FoodManageGet.Application.CommandHandler.BenchTableCommandHandler
{
    /// <summary>
    /// 台费反填
    /// </summary>
    public class BenchTableBackCommandHandler : IRequestHandler<BenchTableBackCommand, BenchTableModel>
    {
        private readonly IBenchTableRepository _benchTableRepository;

        public BenchTableBackCommandHandler(IBenchTableRepository benchTableRepository)
        {
            _benchTableRepository = benchTableRepository;
        }
        public async Task<BenchTableModel> Handle(BenchTableBackCommand request, CancellationToken cancellationToken)
        {
            var list = await _benchTableRepository.GetAllAsync();
            var list1 = list.OrderByDescending(x => x.BenchTableId).FirstOrDefault();
            return list1;
        }
    }
}
